﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Linq;
using System.Data.Linq.Mapping;
using System.Linq;
using System.Text;
using System.Xml.Serialization;
using Chowpoo.Sql;

namespace CourseSystem.Core.Entities
{
    [Table(Name = "RadioChoices")]
    public class RadioChoicesInfo : IDetach
    {
        public RadioChoicesInfo()
        {
            Detach();
        }
        #region Model
        private int _id;
        private int _rid = 0;
        private string _title = "";
        private bool _isanswer = false;

        private EntityRef<QuestionLibInfo> _questionLibInfo;

        [System.Data.Linq.Mapping.Association(Storage = "_questionLibInfo", ThisKey = "Rid", OtherKey = "Id", IsForeignKey = true)]
        [XmlIgnore]
        public QuestionLibInfo QuestionLibInfo
        {
            get { return _questionLibInfo.Entity; }
            set { _questionLibInfo.Entity = value; }
        }

        /// <summary>
        /// 
        /// </summary>
        [Column(IsDbGenerated = true, IsPrimaryKey = true, IsVersion = true)]
        public int Id
        {
            set { _id = value; }
            get { return _id; }
        }
        /// <summary>
        /// 
        /// </summary>
       [Column]
        public int Rid
        {
            set { _rid = value; }
            get { return _rid; }
        }
        /// <summary>
        /// 
        /// </summary>
        [DisplayName("选项名称")]
        [Required(ErrorMessage="必须填写")]
        [Column]
        public string Title
        {
            set { _title = value; }
            get { return _title; }
        }
        /// <summary>
        /// 
        /// </summary>
        [DisplayName("是否答案")]
        [Column]
        public bool IsAnswer
        {
            set { _isanswer = value; }
            get { return _isanswer; }
        }
        #endregion Model

        public void Detach()
        {
            _questionLibInfo = default(EntityRef<QuestionLibInfo>);
        }
    }
}
